<?php

	echo $accessibility->whereIAm($pageTitle,array(array('title'=>'Mensagens','link'=>'/messages'),array('title'=>'Visualizar mensagem')));
	echo $this->renderElement('message');
	echo "<h2 id='contentTitle'>".$pageTitle."</h2>";
	echo "<div id='view'>";

	echo "<p><label>Remetente: </label><span>".$message['From']['name']."</span></p>";
	echo "<p><label>Data: </label><span>".date('d/m/Y - G:i',strtotime($message['Message']['created']))."</span></p>";
	echo "<p><label>Assunto: </label><span>".$message['Message']['subject']."</span></p>";
	echo "<p><label>Mensagem: </label></p>";
	echo "<span>".$message['Message']['text']."</span>";

	echo "<br />";
	echo "<br />";

	/* Botoes - Inicio */
	$entity = 'messages';
	$model = 'Message';
	$label = 'mensagem';
	$label_plural = 'mensagens';

	echo "<div class='buttonBox'>";
	echo "<div class='buttonMinibox'>";
	$listButton = "<span class=\"buttonList\">Listar ".$label_plural."</span>";
	echo html_entity_decode($html->link($listButton, '/'.$entity.'/',array('class'=>'button')));
	echo "</div>";
	echo "<div class='buttonMinibox'>";
	if ($othAuth->hasPermission($entity.'/send/'.$message['To']['id'])) {
		$editButton = "<span class=\"buttonEdit\">Responder</span>";
		echo html_entity_decode($html->link($editButton, '/'.$entity.'/send/'.$message['From']['id'].'/'.$message['Message']['id'] ,array('class'=>'button')));
	}
	echo "</div>";
	echo "<div class='buttonMinibox'>";
	if ($othAuth->hasPermission($entity.'/delete/')) {
		$deleteButton = "<span class=\"buttonDelete\">Apagar ".$label."</span>";
		echo html_entity_decode($html->link($deleteButton,'/'.$entity.'/delete/'.$message[$model]['id'], array('class'=>'button'), 'Confirma a exclusão deste item?'));
	}
	echo "</div>";
	echo "</div>";
	/* Botoes - Fim */

	echo "</div>";